package converter

class SingleDependencyRender {

	/**
	 * Construct and return the signature of a dependency, including it's version and
	 * classifier if it exists
	 */
	public def contructSignature(it) {
	  def gradelDep = "${it.groupId.text()}:${it.artifactId.text()}:${it?.version?.text()}"
	  def classifier = elementHasText(it.classifier) ? gradelDep + ":" + it.classifier.text().trim() : gradelDep
	  return classifier
	}

//	/**
//	 * Print out the basic form og gradle dependency
//	 */
//	private def createBasicDependency(it, build, String scope) {
//	  def classifier = contructSignature(it)
//	  build.append("\t${scope} \"${classifier}\"\n")
//	}

//	/**
//	 * complex print statement does one extra task which is
//	 * iterate over each
//	 * �exclusion� node and print out the artifact id.
//	 */
//	private def createComplexDependency(it, build, scope) {
//	  build.append("\t${scope}(\"${contructSignature(it)}\") {\n")
//	  it.exclusions.exclusion.each() {
//		build.append("\t\texclude(module: '${it.artifactId}')\n")
//	  }
//	  build.append("\t\t}\n")
//	}

//	/**
//	 * Print out the basic form og gradle dependency
//	 */
//	private String createProjectDependency(it, String scope) {
//	  build.append("\t${scope} project(':${it.artifactId}')\n")
//	}~
	
	/**
	 * Check to see if the selected node has content
	 */
	private boolean elementHasText(it) {
	  return it.text().length() != 0
	}
	
}
